<?php
declare (strict_types = 1);

namespace app\api\controller;
use app\BaseController;
use app\api\service\CartService;

class CartController extends BaseController
{

    /**
     * 购物车添加商品
     * @return \think\response\Json
     */
    public function careAdd()
    {
        $u_id= intval( $this->request->get('uid'));
        $g_id= intval( $this->request->get('gid'));
        CartService::careAdd($u_id,$g_id);
     }

    /**
     * @return \think\response\Json
     * 购物车减少物品 以及判断当商品为1件时 减少就是删除
     */
    public function carerReduce()
    {
        $u_id= intval( $this->request->get('uid'));
        $g_id= intval( $this->request->get('gid'));
        CartService::carerReduce($u_id,$g_id);
    }
    /**
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * 购物车查询列表
     */
    public function careList()
    {
        $u_id= intval( $this->request->get('uid'));
        CartService::careList($u_id);
    }

    /**
     * @return \think\response\Json
     * 购物车的删除
     */
    public function delelist()
    {
        $u_id= intval( $this->request->get('uid'));
        $g_id= intval( $this->request->get('gid'));
        CartService::delelist($u_id,$g_id);

    }
}
